fix: finalize code-owner fallback worktree before cleanup - #164
Open
cwbcheng wants to merge 1 commit into
Open
Conversation
The code-owner fallback agent is asked to commit and push its own changes, but agents sometimes finish without doing so (e.g. a truncated model response). Previously PatchDeck marked the fallback run completed and removed the worktree, discarding the agent's edits and leaving the PR branch and review threads untouched. After a successful fallback agent run, PatchDeck now: - commits any uncommitted agent edits in the worktree, - pushes the local head to the PR head branch, - verifies the remote head matches the local head. Adds a regression test that a fallback agent leaving uncommitted edits results in git add/commit/push to the PR branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The code-owner fallback agent is asked (in its prompt) to commit and push its own changes. But agents — especially slower model-backed ones — frequently finish without doing so: they edit files, then return a successful exit without committing or pushing.
Previously, PatchDeck marked the fallback run
completedand removed the worktree in afinallyblock, discarding the agent's edits. The PR branch stayed at the old head and review threads were never resolved, even though the agent had done real work. We observed a run that modified 21 files (a correct fix for a review comment) and then lost all of it.Changes
server/babysitter.ts— after a successful code-owner fallback agent run, before the worktree is cleaned up, PatchDeck now finalizes the PR branch:git add -A+git commit).git push <remote> HEAD:<headRef>).If the agent already committed and pushed,
git status --porcelainis empty and the push is a no-op success — the verification still confirms the head matches.Tests
runQueuedBabysitPR commits and pushes uncommitted code-owner fallback agent changes— a fallback agent that leaves uncommitted edits results ingit add -A,git commit, andgit push HEAD:<branch>to the PR branch.Environment